package bancosys.tec.services.api;

import java.math.BigDecimal;

import bancosys.tec.persist.base.enumx.IntValuedEnum;
import bancosys.tec.persist.base.enumx.StringValuedEnum;
import bancosys.tec.utils.date.Date;

/**
 * Decora os metodos assert* para não executar a validação caso o parametro "expected" seja <code>null</code>. Ou seja o usuario não informe
 * qual o valor esperado em um serviço de validação.
 * 
 * @author Rafael Volpato
 * @date Sep 8, 2009
 */
public class IgnoreNullServiceValidator extends ServiceValidator {

    /**
     * {@inheritDoc}
     */
    @Override
    public void assertEquals(String fieldName, BigDecimal expected, BigDecimal got) {
        if (expected != null) {
            super.assertEquals(fieldName, expected, got);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void assertEquals(String fieldName, BigDecimal expected, BigDecimal got, double precision) {
        if (expected != null) {
            super.assertEquals(fieldName, expected, got, precision);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void assertEquals(String fieldName, Date expected, Date got) {
        if (expected != null) {
            super.assertEquals(fieldName, expected, got);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void assertEquals(String fieldName, IntValuedEnum expected, IntValuedEnum got) {
        if (expected != null) {
            super.assertEquals(fieldName, expected, got);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void assertEquals(String fieldName, Object expected, Object got) {
        if (expected != null) {
            super.assertEquals(fieldName, expected, got);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void assertEquals(String fieldName, StringValuedEnum expected, StringValuedEnum got) {
        if (expected != null) {
            super.assertEquals(fieldName, expected, got);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void assertEqualsExact(String fieldName, BigDecimal expected, BigDecimal got) {
        if (expected != null) {
            super.assertEqualsExact(fieldName, expected, got);
        }
    }
}
